package com.lsj.mapper.entity;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * @Author:lin.sj
 * @Data:2021/7/6 13:34
 * @Desc:
 * 1.目前数据库表里面没有定义accountNonExpired、accountNonLocked、credentialsNonExpired这三个字段,暂时不需要使用到那么多字段，有需要的时候再增加就好了
 * 2.因为使用mybatis-plus生成代码，所以使用继承的方式来实现，避免重新生成后会覆盖修改的实体内容
 */
@Data
public class MyUserDetail extends SysUser implements UserDetails,Serializable {

    /**用户的权限集合**/
    List<GrantedAuthority> authorities ;
    /**用户关联的组织机构**/
    SysOrg sysOrg;
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }
    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return super.getEnabled();
    }
}
